package com.baosight.sczx.common.zm.cInterface.cm;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.iplat4j.ep.ServiceEPBase;

/**
 * 二级物资库存 
 * <p>Title: Level2MaterialBase.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 杨鸣
 * @version 1.0
 * <pre>Histroy:
 *          2011-09-28 下午03:14:52  高强  Create
 *</pre>
 */
public class Level2MaterialBase extends ServiceEPBase {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	
	

	/**根据盘点结果更新二级库存账
	 * <p>Function updateStockValue</p>
	 * @param inInfo
	 * @param string
	 * @param name
	 *  <p>History:
	 *    2011-09-28 下午03:14:52   高强
	 * </p>
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static EiInfo updateStockValue(EiInfo inInfo) {
		Map<String, String> _map = new HashMap<String, String>();
		_map = (HashMap)inInfo.getBlock("result").getRows().get(0);
		dao.update("ZMCM2levelmaterialbase.updatestockvalue",_map );//更新库存数量
		return inInfo;
	}
	
	/**
	 * 不知道谁写的方法
	 * 看到了请补充说明
	 * <p>Function: getStockValue</p>
	 * <p>Description: </p>
	 * <p>return value:EiInfo</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-10-13上午02:11:45 严洪浩
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static EiInfo getStockValue(EiInfo inInfo) {
		String fdMaterialInnerCode = inInfo.get("fdMaterialInnerCode").toString();//物资内码
		String fdDepotCode = inInfo.get("fdDepotCode").toString();//库房编码
		
		Map<String, String> _map = new HashMap<String, String>();
		_map.put("fdMaterialInnerCode", fdMaterialInnerCode);
		_map.put("fdDepotCode", fdDepotCode);
		List<Map> _list = new ArrayList<Map>();
		_list  = dao.query("ZMCM2levelmaterialbase.querystockvalue", _map);
		String fdNum="0";
		
		if(_list.size()>0){
		   fdNum = _list.get(0).get("fdNum").toString();
		}
		EiInfo outInfo=new EiInfo();
		outInfo.set("fdAccountSum",fdNum);
		outInfo.set("fdHasInvoiceNum","0");
		outInfo.set("fdNoInvoiceNum","0");
		return outInfo;
	}
}
